package com.chuji.crmcj.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.chuji.crmcj.R;
import com.chuji.crmcj.bean.FullPayInfo;
import com.chuji.crmcj.utils.UIUtils;

import java.util.List;

/**
 * Created by w.pitt on 2016/1/21.
 */
public class FullPayAdapter extends BaseAdapter {
    private Context mContext;
    private List<FullPayInfo.ApiParamObjEntity> fullPayInfo;

    public FullPayAdapter(Context mContext, List<FullPayInfo.ApiParamObjEntity> fullPayInfo) {
        this.mContext = mContext;
        this.fullPayInfo = fullPayInfo;
    }

    @Override
    public int getCount() {
        return fullPayInfo.isEmpty() ? 0 : fullPayInfo.size();
    }

    @Override
    public Object getItem(int i) {
        return fullPayInfo.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    private ViewHolder holder;

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = view.inflate(UIUtils.getContext(), R.layout.item_coustomer_list, null);
            holder = new ViewHolder();
            ImageView mIvLevel = (ImageView) view.findViewById(R.id.iv_level);
            mIvLevel.setVisibility(View.GONE);

            holder.mTvDealCar = (TextView) view.findViewById(R.id.tv_want_car);
//          holder.mTvSalerName = (TextView) view.findViewById(R.id.tv_sale_name);
            holder.mTvLeastTime = (TextView) view.findViewById(R.id.tv_least_time);
            holder.mTvCusName = (TextView) view.findViewById(R.id.tv_name);
            holder.mTvCusNum = (TextView) view.findViewById(R.id.tv_number);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.mTvDealCar.setText(fullPayInfo.get(i).getCarModel());
        holder.mTvCusNum.setText(fullPayInfo.get(i).getTel());
        holder.mTvLeastTime.setText(fullPayInfo.get(i).getCreateTime());
        holder.mTvCusName.setText(fullPayInfo.get(i).getName());
        return view;
    }

    public List<FullPayInfo.ApiParamObjEntity> getList() {
        return fullPayInfo;
    }

    static class ViewHolder {
        private TextView mTvDealCar;
        private TextView mTvSalerName;
        private TextView mTvCusName;
        private TextView mTvCusNum;
        private TextView mTvLeastTime;
    }
}
